local size = redis.call('LLEN', KEYS[1])
if size == 0 then
    error("empty list")
end
local i = redis.call('GET', KEYS[2])
if not i then
    i = 0
end
local v = redis.call('LINDEX', KEYS[1], i)
local newIndex = ( i + 1 ) % size
redis.call('SET', KEYS[2], newIndex)
return v

